<?php require_once('finance/inc/item_kind.php'); ?>
<?php 

$kind = intval($_GET['kind']); 
$lmcy_id = @intval($_GET['lmcy_id']);

$lmcys = dt_query("SELECT id, name FROM finance_lmcy ORDER BY c_at");
if (!$lmcys) die('获取数据失败！');

?>
<?php require_once('finance/inc/nav_sub_rz.html') ?>
<div class="container finance-item-add" style="padding-top:15px">
	<div class="row clearfix">
		<div class="col-md-12 column">
			<h3><span class="glyphicon glyphicon-edit"></span> <?php echo $item_kind[$kind]['name'] ?></h3>
			<hr class="solid">
			<div class="alert alert-info">
				<b>提示</b>
				<ol>
					<li>请仔细填写您的真实信息，我们将与您取得联系。</li>
				</ol>
			</div>
			<div class="col-md-11 column">
				<form class="form-horizontal" action="?c=finance&a=do_item_add" method="post">
					<fieldset>

						<!-- kind -->
						<input type="hidden" name="kind" value="<?php echo $kind ?>"/>

						<!-- Text input-->
						<div class="form-group">
							<label class="col-md-2 control-label">项目名称</label>  
							<div class="col-md-7">
								<input name="name" type="text" placeholder="某某项目" class="form-control input-md" required="">
							</div>
						</div>

						<!-- Text input-->
						<div class="form-group">
							<label class="col-md-2 control-label">融资金额</label>  
							<div class="col-md-7">
								<input name="money" type="text" placeholder="000.00" class="form-control input-md" required="">
							</div>
						</div>

						<!-- Text input-->
						<div class="form-group">
							<label class="col-md-2 control-label">年化收益</label>  
							<div class="col-md-7">
								<input name="revenue" type="text" placeholder="8.25%" class="form-control input-md" required="">
							</div>
						</div>

						<!-- Text input-->
						<div class="form-group">
							<label class="col-md-2 control-label">融资期限</label>  
							<div class="col-md-7">
								<input name="term" type="text" placeholder="3个月" class="form-control input-md" required="">
							</div>
						</div>

						<!-- Text input-->
						<div class="form-group">
							<label class="col-md-2 control-label">项目区域位置</label>  
							<div class="col-md-7">
								<input name="location" type="text" placeholder="雁峰区白沙洲工业园内" class="form-control input-md" required="">
							</div>
						</div>

						<!-- Text input-->
						<div class="form-group">
							<label class="col-md-2 control-label">资金用途</label>  
							<div class="col-md-7">
								<input name="use_to" type="text" placeholder="企业经营用途.企业经营流动性资金" class="form-control input-md" required="">
							</div>
						</div>

						<!-- Text input-->
						<div class="form-group">
							<label class="col-md-2 control-label">项目情况</label>  
							<div class="col-md-7">
								<textarea name="item_info" type="text" placeholder="公司成立于xxxx年x月，注册资本xxxx万元，属自然人出资有限公司。公司经营范围谷物种植；水果、肉、禽、蛋、水产品销售；冷藏、冷冻服务；蔬菜种植、收购、销售。本次贷款主体为公司的法定代表人。" class="form-control input-md" rows="3" required=""></textarea>
							</div>
						</div>

						<!-- Text input-->
						<div class="form-group">
							<label class="col-md-2 control-label">借款用途</label>  
							<div class="col-md-7">
								<input name="use_to_do" type="text" placeholder="公司的经营周转，补充流动资金。" class="form-control input-md" required="">
							</div>
						</div>

						<!-- Text input-->
						<div class="form-group">
							<label class="col-md-2 control-label">还款来源</label>  
							<div class="col-md-7">
								<input name="income" type="text" placeholder="公司经营收入。" class="form-control input-md" required="">
							</div>
						</div>
						<hr class="dashed">
						<!-- Text input-->
						<div class="form-group">
							<label class="col-md-2 control-label">机构选择</label>  
							<div class="col-md-7">
								<select name="lmcy_id" class="form-control">
									<?php while($lmcy = mysql_fetch_array($lmcys)) { ?>
									<option value="<?php echo $lmcy['id'] ?>"><?php echo $lmcy['name'] ?></option>
									<?php } ?>
								</select>
								<span class="help-block">这是为您操作项目的投融资服务机构。</span>
							</div>
						</div>
						<!-- Text input-->
						<div class="form-group">
							<label class="col-md-2 control-label">联系电话</label>  
							<div class="col-md-7">
								<input name="phone" type="text" placeholder="158****8888" class="form-control input-md" required="">
								<span class="help-block">我们的专业人员通过这个号码与您联系。</span>
							</div>
						</div>
						<!-- token -->
						<input type="hidden" name="token" value="<?php echo get_token() ?>"/>

						<!-- Button -->
						<div class="form-group">
							<label class="col-md-2 control-label"></label>
							<div class="col-md-2">
								<button onclick="save_input()" class="btn btn-primary btn-block <?php if (empty($_SESSION['auth'])) echo "disabled"; ?>">提交申请</button>
							</div>
							<div class="col-md-5">
								<a class="btn btn-success btn-block <?php if (!empty($_SESSION['auth'])) echo "disabled"; ?>" type="button" href="javascript:save_input();jump_to_login('?c=finance&a=item_add&kind=<?php echo $kind ?>')">登录后提交</a>
							</div>
						</div>

					</fieldset>
				</form>	


			</div>
		</div>
	</div>
</div>

<script type="text/javascript">

$(document).ready(function(){
	$("li#finance_rz").addClass("active");
	$('li#rz_ptrz').addClass('active');
	$('select[name=lmcy_id]').find('option[value=<?php echo $lmcy_id ?>]').attr('selected', true);
	recover_input(); 
});
function recover_input() {
	$("input").each(function(){
		if ('token' == $(this).attr('name')) return;
		if ('kind' == $(this).attr('name')) return;
		$(this).val(getCookie('item_add_'+$(this).attr('name'))); 
	});
	$("textarea").each(function(){ $(this).html(getCookie('item_add_'+$(this).attr('name'))); });
}
function save_input() {
	$("input").each(function(){ setCookie('item_add_'+$(this).attr('name'), $(this).val(), 365, '/'); });
	$("textarea").each(function(){ setCookie('item_add_'+$(this).attr('name'), $(this).val(), 365, '/'); });
}

</script>
